package cn.tansanqinger.controller.account;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.tansanqinger.service.comment.ICommentTopicService;
import cn.tansanqinger.service.hymenu.IHyMenuServer;
import cn.tansanqinger.util.PageData;

@Controller
@RequestMapping("/account/user")
public class AccountCommentController {
	
	@Autowired
	private IHyMenuServer hyMenuServer;
	@Autowired
	private ICommentTopicService topicService;
	
	@RequestMapping("/comment")
	public ModelAndView list(ModelAndView mv, HttpServletRequest request) {
		mv = hyMenuServer.selectHyMenuAll(mv);
		mv.addObject("user", request.getSession().getAttribute("user"));
		mv.addObject("commentList", topicService.selectUserAll(request));
		mv.addObject("commentNumber", topicService.selectUserAllNumber(request));
		mv.addObject("page", 1);
		mv.setViewName("account/comment");
		return mv;
	}
	
	@RequestMapping("/loadMore")
	@ResponseBody
	public PageData loadMore(ModelAndView mv, HttpServletRequest request) {
		PageData resultPage = new PageData();
		resultPage.put("commentList", topicService.selectUserAll(request));
		resultPage.put("commentNumber", topicService.selectUserAllNumber(request));
		return resultPage;
	}
}
